class VideoTest extends egret.DisplayObjectContainer {
	video:egret.Video;
	playBtn:Button;
	playing:boolean = false;
	public constructor() {
		super();

		this.video = new egret.Video();
		this.video.x = 150;
		this.video.y = 15;
		this.video.width = 640;
		this.video.height = 320;
		this.video.fullscreen = false;
		this.video.poster = "resource/bg.jpg";
		let url = "resource/trailer.mp4"; //http://media.w3.org/2010/05/sintel/trailer.mp4
		this.video.load(url);
		this.addChild(this.video);
		this.video.once(egret.Event.COMPLETE,this.onLoad,this);
		this.video.once(egret.IOErrorEvent.IO_ERROR,this.onError,this);

		this.playBtn = new Button();
		this.addChild(this.playBtn);
		this.playBtn.label = "播 放";
		this.playBtn.x = this.video.x;
		this.playBtn.y = this.video.y + this.video.height+10;

	}
	private onLoad(){
		console.log("video loaded");
		this.playBtn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick,this);
	}
	private onError(){
		console.log("video onError");
	}

	private onClick(e:egret.TouchEvent):void
	{
		console.log("this.video.paused",this.video.paused);
		if(!this.playing)
		{
			this.video.play(this.video.position,true);
			this.playBtn.label = "暂 停";
		}else
		{
			this.video.pause();
			this.playBtn.label = "播 放";
			console.log("this.video.paused 11",this.video.paused);
		}
		this.playing = !this.playing;
	}

}